namespace NHCodeFirst.FluentMapper
{
    using NHibernate.Cfg;

    public class FluentMapper
    {
        private Configuration configuration;

        internal bool ConfigedByCode
        {
            get { return configuration != null; }
        }

        public Configuration Configuration
        {
            get { return configuration ?? (configuration = new Configuration()); }
        }

        public EntityMemberMapper<TEntity> Entity<TEntity>()
        {
            var entityType = typeof(TEntity);
            if (!NHibernateConfiguration.MappingModels.ContainsKey(entityType))
                NHibernateConfiguration.AddToMapModels(entityType);
            return new EntityMemberMapper<TEntity>(NHibernateConfiguration.MappingModels[entityType].Class);
        }
    }
}